package com.example.hotel_lxy.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.widget.Toolbar;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.example.hotel_lxy.R;
import com.example.hotel_lxy.application.ARouterPath;
import com.example.hotel_lxy.view.LollipopFixedWebView;
import com.ysxsoft.common_base.base.BaseActivity;
import com.ysxsoft.common_base.utils.WebViewUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * web
 */
@Route(path = "/main/WebActivity")
public class WebActivity extends BaseActivity {

    @Autowired
    String url;
    @Autowired
    String titlename;
    @BindView(R.id.webView)
    LollipopFixedWebView webView;
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.toolbar)
    Toolbar toolbar;

    public static void start(String url,String titlename) {
        ARouter.getInstance().build(ARouterPath.getWebActivity())
                .withString("url", url)
                .withString("titlename",titlename)
                .navigation();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_web;
    }

    @Override
    public void doWork() {
        ARouter.getInstance().inject(this);
        super.doWork();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        WebViewUtils.init(webView);
        webView.loadUrl("" + url);
        title.setText(titlename);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}